package com.chunxiadong.service.impl;

import com.chunxiadong.entity.Comment;
import com.chunxiadong.mapper.CommentMapper;
import com.chunxiadong.service.CommentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Date;
import java.util.List;

/**
 * @auther QiuShangcheng
 * @create 2021/6/9
 */
@Service
public class CommentServiceImpl implements CommentService {
    @Autowired
    CommentMapper commentMapper;

    @Transactional
    @Override
    public int addComment(Comment comment) {
        comment.setCreateTime(new Date());
        return commentMapper.addComment(comment);
    }

    @Transactional
    @Override
    public List<Comment> getCommentListByBlogId(Integer id) {
        return commentMapper.getCommentListByBlogId(id);
    }
}
